﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Theme_DL_NoteOfSingle :PowerCreator.LMS.Web.Base.WebBasePage
{
    PowerCreator.LMS.Web.DL.Project.TONote opNote = new PowerCreator.LMS.Web.DL.Project.TONote();
    protected PowerCreator.LMS.Web.Config.WebConfig config = new PowerCreator.LMS.Web.Config.WebConfig();
    private PowerCreator.LMS.Web.DL.User.LoginEntity login = new PowerCreator.LMS.Web.DL.User.LoginEntity();

    protected void Page_Load(object sender, EventArgs e)
    {
        this.Title = "个人课程学习笔记";
        ViewState["CourseID"] = "0";
        if (!IsPostBack)
        {
            string courseID = Request.QueryString["CourseID"].ToString();
            ViewState["CourseID"] = courseID;
            string search = GetSearch(courseID);

            BinderPager(search);
            BinderRPT(search, 1);
        }
    }
    protected override void InitPage()
    {
        
        base.InitPage();
    }


    private string GetSearch(string courseid)
    {
        login = (PowerCreator.LMS.Web.DL.User.LoginEntity)Session[PowerCreator.LMS.Web.Config.WebConfig.SESSION_USER_USERINFO];
        string search = "";
        if (login != null)
            search = "  Creator=" + login.UserID.ToString();
        return search;
    }

    protected void BinderPager(string search)
    {
        AspNetPager1.RecordCount = opNote.Count(search);
        AspNetPager1.PageSize = PowerCreator.LMS.Web.Config.WebConfig.PageSize;
        PreAspNetPager(AspNetPager1);
    }

    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        string search = GetSearch(ViewState["CourseID"].ToString());
        BinderRPT(search, AspNetPager1.CurrentPageIndex);
    }
    private void BinderRPT(string search, int pageIndex)
    {
        PowerCreator.LMS.DL.Project.Entity.VOTOLearner vo = new PowerCreator.LMS.DL.Project.Entity.VOTOLearner();
        PowerCreator.LMS.Web.DL.Project.TOLearner oplearner=new PowerCreator.LMS.Web.DL.Project.TOLearner();
        DataTable dt = new DataTable();
        dt = opNote.Query(search, "",PowerCreator.LMS.Web.Config.WebConfig.PageSize, pageIndex);
        dt.Columns.Add("RealName");
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            vo = oplearner.Load(int.Parse(dt.Rows[i]["Creator"].ToString()));
            dt.Rows[i]["RealName"] = vo.Name;
        }
        rpt_Refer.DataSource = dt;
        rpt_Refer.DataBind();

    }
}
